package com.autel.webrtc.demo.common.storage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.autel.webrtc.demo.common.SystemContext;
import org.springframework.util.Assert;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class GroupReadyStorage {

    private ConcurrentHashMap<String,List<String>> groupIdUsersMap=new ConcurrentHashMap<>();
    private ConcurrentHashMap<String,String> groupIdCodeMap=new ConcurrentHashMap<>();

    public  void   createGroupOfCode(String groupCode){
        Assert.isTrue(StrUtil.isNotBlank(groupCode),"房间编号不能为空");
        String groupId=groupIdCodeMap.get(groupCode);
        if (StrUtil.isNotBlank(groupId)){
          List<String>  userIds=  groupIdUsersMap.get(groupId);
          if (CollUtil.isNotEmpty(userIds))  {
              userIds.add(SystemContext.getUserId());
          }else{
              userIds=CollUtil.newArrayList(SystemContext.getUserId());
          }
        }
    }
}
